// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Serverless.Fluent;
using Elastic.Clients.Elasticsearch.Serverless.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Serverless.IndexManagement;

public sealed partial class MappingLimitSettingsDepth
{
	/// <summary>
	/// <para>The maximum depth for a field, which is measured as the number of inner objects. For instance, if all fields are defined<br/>at the root object level, then the depth is 1. If there is one object mapping, then the depth is 2, etc.</para>
	/// </summary>
	[JsonInclude, JsonPropertyName("limit")]
	public long? Limit { get; set; }
}

public sealed partial class MappingLimitSettingsDepthDescriptor : SerializableDescriptor<MappingLimitSettingsDepthDescriptor>
{
	internal MappingLimitSettingsDepthDescriptor(Action<MappingLimitSettingsDepthDescriptor> configure) => configure.Invoke(this);

	public MappingLimitSettingsDepthDescriptor() : base()
	{
	}

	private long? LimitValue { get; set; }

	/// <summary>
	/// <para>The maximum depth for a field, which is measured as the number of inner objects. For instance, if all fields are defined<br/>at the root object level, then the depth is 1. If there is one object mapping, then the depth is 2, etc.</para>
	/// </summary>
	public MappingLimitSettingsDepthDescriptor Limit(long? limit)
	{
		LimitValue = limit;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (LimitValue.HasValue)
		{
			writer.WritePropertyName("limit");
			writer.WriteNumberValue(LimitValue.Value);
		}

		writer.WriteEndObject();
	}
}